<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>用JS任意控制手机上的APP | RobotJs | 用JS任意控制手机上的APP</title>
  <link rel="stylesheet" href="assets/fonts.css">
  <link rel="stylesheet" href="assets/style.css">
  <link rel="stylesheet" href="assets/sh.css">
  <link rel="canonical" href="https://nodejs.org/api/startnow.html">
</head>
<body class="alt apidoc" id="api-section-startnow">
  <div id="content" class="clearfix">
    <div id="column2" class="interior">
      <div id="intro" class="interior">
        <a href="/" title="返回首页">
          RobotJs
        </a>
      </div>
      <ul>
<li><a class="nav-startnow active" href="startnow.html">开始</a></li>
<li><a class="nav-hbuilder" href="hbuilder.html">Demo, 调试运行</a></li>
<li><a class="nav-hello" href="hello.html">Hello World</a></li>
<li><a class="nav-autojs-vue" href="autojs-vue.html">与vue交互</a></li>
<li><a class="nav-normal" href="normal.html">常用api</a></li>
<li><a class="nav-links" href="links.html">支持库(超强)</a></li>
<li><a class="nav-patchs" href="patchs.html">热更新</a></li>
<li><a class="nav-deploy" href="deploy.html">打包</a></li>
<li><a class="nav-remote" href="remote.html">远程部署</a></li>
<li><a class="nav-java" href="java.html">与java交互</a></li>
<li><a class="nav-qa" href="qa.html">Q&amp;A - 常见问题</a></li>
<li><a class="nav-https-miren-lovemi-ren-colorui-document-" href="https://miren.lovemi.ren/colorui-document/" target="_blank" rel="noopener noreferrer">UI设计</a><div class="line"></div></li>
<li><a class="nav--" href="#">【API文档】:</a></li>
<li><a class="nav-overview" href="overview.html">Overview - 综述</a></li>
<li><a class="nav-documentation" href="documentation.html">Tip - 阅读说明</a></li>
<li><a class="nav-coordinatesBasedAutomation" href="coordinatesBasedAutomation.html">Click - 基于坐标的操作</a></li>
<li><a class="nav-widgetsBasedAutomation" href="widgetsBasedAutomation.html">开始 - 基于控件的操作</a></li>
<li><a class="nav-widgetsBasedAutomation-widgetsbasedautomation_simpleactionautomator" href="widgetsBasedAutomation.html#widgetsbasedautomation_simpleactionautomator">Click - 基于控件的操作</a></li>
<li><a class="nav-widgetsBasedAutomation-widgetsbasedautomation_uiselector" href="widgetsBasedAutomation.html#widgetsbasedautomation_uiselector">UiSelector - 查找控件</a></li>
<li><a class="nav-widgetsBasedAutomation-widgetsbasedautomation_uiobject" href="widgetsBasedAutomation.html#widgetsbasedautomation_uiobject">UiObject - 控件</a></li>
<li><a class="nav-app" href="app.html">App - 应用</a></li>
<li><a class="nav-canvas" href="canvas.html">Canvas - 画布</a></li>
<li><a class="nav-console" href="console.html">Console - 控制台</a></li>
<li><a class="nav-crypto" href="crypto.html">Crypto - 加解密与消息摘要</a></li>
<li><a class="nav-device" href="device.html">Device - 设备</a></li>
<li><a class="nav-dialogs" href="dialogs.html">Dialogs - 对话框</a></li>
<li><a class="nav-engines" href="engines.html">Engines - 脚本引擎</a></li>
<li><a class="nav-events" href="events.html">Events - 事件与监听</a></li>
<li><a class="nav-floaty" href="floaty.html">Floaty - 悬浮窗</a></li>
<li><a class="nav-files" href="files.html">Files - 文件系统</a></li>
<li><a class="nav-globals" href="globals.html">Globals - 一般全局函数</a></li>
<li><a class="nav-http" href="http.html">Http - HTTP</a></li>
<li><a class="nav-images" href="images.html">Images - 图片与图色处理</a></li>
<li><a class="nav-keys" href="keys.html">Keys - 按键模拟</a></li>
<li><a class="nav-media" href="media.html">Media - 多媒体</a></li>
<li><a class="nav-modules" href="modules.html">Modules - 模块</a></li>
<li><a class="nav-sensors" href="sensors.html">Sensors - 传感器</a></li>
<li><a class="nav-shell" href="shell.html">Shell - Shell命令</a></li>
<li><a class="nav-storages" href="storages.html">Storages - 本地存储</a></li>
<li><a class="nav-threads" href="threads.html">Threads - 多线程</a></li>
<li><a class="nav-timers" href="timers.html">Timers - 定时器</a></li>
<li><a class="nav-ui" href="ui.html">UI - 用户界面</a></li>
<li><a class="nav-https-developer-mozilla-org-zh-CN-docs-Mozilla-Projects-Rhino-Scripting_Java" href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Projects/Rhino/Scripting_Java">Work with Java - 调用Java API</a></li>
</ul>
<div class="line"></div>



    </div>

    <div id="column1" data-id="startnow" class="interior">
      <header>
        <h1>用JS任意控制手机上的APP</h1>
        <div id="gtoc">
          <p>
            <a href="index.html" name="toc">索引</a> |
            <a href="all.html">查看全部</a>
          </p>
        </div>
        <hr>
      </header>

      <div id="toc">
        <h2>目录</h2>
        <ul>
<li><span class="stability_undefined"><a href="#startnow_js_app">用JS任意控制手机上的APP</a></span><ul>
<li><span class="stability_undefined"><a href="#startnow_1">1. 控制代码</a></span></li>
<li><span class="stability_undefined"><a href="#startnow_uni_app_autojs">本项目完全兼容  uni-app + autoJs</a></span></li>
<li><span class="stability_undefined"><a href="#startnow_uni_app_autojs_https_uniapp_dcloud_net_cn"><a href="https://uniapp.dcloud.net.cn/">本项目完全兼容  uni-app + autoJs</a></a></span></li>
<li><span class="stability_undefined"><a href="#startnow">声明</a></span></li>
<li><span class="stability_undefined"><a href="#startnow_qq_862460452">QQ群： 862460452</a></span></li>
<li><span class="stability_undefined"><a href="#startnow_2">2.开发环境</a></span><ul>
<li><span class="stability_undefined"><a href="#startnow_2_1_https_github_com_yooge_robot">2.1 下载代码  https://github.com/yooge/robot</a></span></li>
<li><span class="stability_undefined"><a href="#startnow_2_2_nodejs_http_www_nodejs_com_cn">2.2 下载<a href="http://www.nodejs.com.cn/">NodeJs</a></a></span></li>
<li><span class="stability_undefined"><a href="#startnow_2_3_hbuilderx_https_www_dcloud_io_hbuilderx_html">2.3 下载安装开发工具<a href="https://www.dcloud.io/hbuilderx.html">HbuilderX</a></a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#startnow_3">3.初始化环境</a></span><ul>
<li><span class="stability_undefined"><a href="#startnow_3_0_hbuilder">3.0 用Hbuilder打开项目 <code>(菜单/文件/打开目录)</code></a></span></li>
<li><span class="stability_undefined"><a href="#startnow_2_1">点击如图菜单可完成如下2步操作</a></span><ul>
<li><span class="stability_undefined"><a href="#startnow_3_1_npm_i">3.1 更新支持库(依赖包)，点击如下菜单，会执行 <code>npm i</code></a></span></li>
<li><span class="stability_undefined"><a href="#startnow_3_2_robot_tools_init">3.2 更新运行基座【请忽略】，点击如下菜单，会执行 <code>robot-tools init</code></a></span></li>
</ul>
</li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#startnow_4">4.运行程序</a></span></li>
<li><span class="stability_undefined"><a href="#startnow_5">5.代码结构</a></span></li>
<li><span class="stability_undefined"><a href="#startnow_qq_862460452_1">QQ群：  862460452</a></span></li>
</ul>
</li>
</ul>

      </div>

      <div id="apicontent">
        <h1>用JS任意控制手机上的APP<span><a class="mark" href="#startnow_js_app" id="startnow_js_app">#</a></span></h1>
<h2>1. 控制代码<span><a class="mark" href="#startnow_1" id="startnow_1">#</a></span></h2>
<div class="signature"><ul>
<li>可以用如下简单的JS代码，控制手机上的第三方APP的行为，实现自动测试等目的 *</li>
</ul>
</div><pre><code>launchApp(&quot;微信&quot;); 
click(&quot;发现&quot;);
click(&quot;朋友圈&quot;);
sleep(3000);
click(desc(&quot;评论&quot;));

</code></pre><h2>本项目完全兼容  uni-app + autoJs<span><a class="mark" href="#startnow_uni_app_autojs" id="startnow_uni_app_autojs">#</a></span></h2>
<h2><a href="https://uniapp.dcloud.net.cn/">本项目完全兼容  uni-app + autoJs</a><span><a class="mark" href="#startnow_uni_app_autojs_https_uniapp_dcloud_net_cn" id="startnow_uni_app_autojs_https_uniapp_dcloud_net_cn">#</a></span></h2>
<h2>声明<span><a class="mark" href="#startnow" id="startnow">#</a></span></h2>
<pre><code>⚠️ 警告：本项目仅供大家学习交流，请勿用于非法目的 ⚠️
⚠️ 警告：本项目之衍生产品，其用途均与本项目作者无关 ⚠️
</code></pre><h2>QQ群： 862460452<span><a class="mark" href="#startnow_qq_862460452" id="startnow_qq_862460452">#</a></span></h2>
<pre><code class="lang-js">  如果喜欢这个项目，可以请赠我一包华子 
</code></pre>
<h2>2.开发环境<span><a class="mark" href="#startnow_2" id="startnow_2">#</a></span></h2>
<h3>2.1 下载代码  <a href="https://github.com/yooge/robot">https://github.com/yooge/robot</a><span><a class="mark" href="#startnow_2_1_https_github_com_yooge_robot" id="startnow_2_1_https_github_com_yooge_robot">#</a></span></h3>
<h3>2.2 下载<a href="http://www.nodejs.com.cn/">NodeJs</a><span><a class="mark" href="#startnow_2_2_nodejs_http_www_nodejs_com_cn" id="startnow_2_2_nodejs_http_www_nodejs_com_cn">#</a></span></h3>
<h3>2.3 下载安装开发工具<a href="https://www.dcloud.io/hbuilderx.html">HbuilderX</a><span><a class="mark" href="#startnow_2_3_hbuilderx_https_www_dcloud_io_hbuilderx_html" id="startnow_2_3_hbuilderx_https_www_dcloud_io_hbuilderx_html">#</a></span></h3>
<pre><code>新版本: https://www.dcloud.io/hbuilderx.html
老版本： https://pan.baidu.com/s/1W0IEokddywK5iqoIx7biKw?pwd=1234 
</code></pre><p><img src="images/start0.png" alt=""></p>
<h2>3.初始化环境<span><a class="mark" href="#startnow_3" id="startnow_3">#</a></span></h2>
<h3>3.0 用Hbuilder打开项目 <code>(菜单/文件/打开目录)</code><span><a class="mark" href="#startnow_3_0_hbuilder" id="startnow_3_0_hbuilder">#</a></span></h3>
<h3>点击如图菜单可完成如下2步操作<span><a class="mark" href="#startnow_2_1" id="startnow_2_1">#</a></span></h3>
<h4>3.1 更新支持库(依赖包)，点击如下菜单，会执行 <code>npm i</code><span><a class="mark" href="#startnow_3_1_npm_i" id="startnow_3_1_npm_i">#</a></span></h4>
<h4>3.2 更新运行基座【请忽略】，点击如下菜单，会执行 <code>robot-tools init</code><span><a class="mark" href="#startnow_3_2_robot_tools_init" id="startnow_3_2_robot_tools_init">#</a></span></h4>
<p><img src="images/start1.png" alt=""></p>
<h2>4.运行程序<span><a class="mark" href="#startnow_4" id="startnow_4">#</a></span></h2>
<p><img src="images/start2.png" alt=""></p>
<h2>5.代码结构<span><a class="mark" href="#startnow_5" id="startnow_5">#</a></span></h2>
<p><img src="images/start3.png" alt=""></p>
<h2>QQ群：  862460452<span><a class="mark" href="#startnow_qq_862460452_1" id="startnow_qq_862460452_1">#</a></span></h2>
<pre><code class="lang-js">  如果喜欢这个项目，可以请赠我一包华子 
</code></pre>

      </div>
    </div>
  </div>
  <script src="assets/sh_main.js"></script>
  <script src="assets/sh_javascript.min.js"></script>
  <script>highlight(undefined, undefined, 'pre');</script>
  <!-- __TRACKING__ -->
</body>
</html>